<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>第二次作业</title>
		<style type="text/css">
			*{
				padding: 0;
				margin: 0;
			}
			.container {
				width: 100vw;
				height: 100vh;
				display: flex;
				align-items: center;
				justify-content: center;
			}
			canvas {
				width: 500px;
				height: 500px;
				border: 2px solid blue;
			}
		</style>
	</head>
	<body>
		<div class="container">
			<canvas id="canvas" width="500" height="500"></canvas>
		</div>
	</body>
	<script>
		window.onload = function(){
			let oCanvas = document.getElementById('canvas');
			
			console.dir(oCanvas);
			
			let oPen = oCanvas.getContext("2d");
			
			console.dir(oPen);
			
			//线的粗细
			oPen.lineWidth = 10;
			
			//脸
			oPen.beginPath();
			// x(圆心), y(圆心), 半径, 开始角度, 结束角度, 是否逆时针画
			oPen.arc(250,250,150,0,Math.PI*2,false);
			oPen.closePath();
			oPen.strokeStyle ="black";
			oPen.fillStyle = "black";
			oPen.fill();
			oPen.stroke();
			
			//右眼
			oPen.beginPath();
			oPen.arc(190,200,20,0,Math.PI*2,false);
			oPen.closePath();
			oPen.strokeStyle ="white";
			oPen.fillStyle = "black";
			oPen.fill();
			oPen.stroke();
			
			//左眼
			oPen.beginPath();
			oPen.arc(310,200,20,0,Math.PI*2,false);
			oPen.closePath();
			oPen.strokeStyle ="white";
			oPen.fillStyle = "black";
			oPen.fill();
			oPen.stroke();
			
			//嘴巴
			oPen.beginPath();
			oPen.arc(250,300,60,0,Math.PI,false);
			oPen.closePath();
			oPen.strokeStyle ="white";
			oPen.fillStyle = "black";
			oPen.fill();
			oPen.lineJoin = "round";
			oPen.stroke();
			
			//耳朵
			oPen.beginPath();
			oPen.arc(100,250,60,0,Math.PI*2,false);
			oPen.closePath();
			oPen.strokeStyle ="black";
			oPen.stroke();
			
			oPen.beginPath();
			oPen.arc(400,250,60,0,Math.PI*2,false);
			oPen.closePath();
			oPen.strokeStyle ="black";
			oPen.stroke();
		}
	</script>
</html>